package org.singleton.ex1;

import java.io.InputStream;
import java.util.Properties;

public class AppConfig2 {
	private static AppConfig2 instance = new AppConfig2();

	private static AppConfig2 getIntance() {
		return instance;
	}

	private String parameterA;
	private String parameterB;

	public String getParameterA() {
		return parameterA;
	}

	public String getParameterB() {
		return parameterB;
	}

	public AppConfig2() {
		readConfig();
	}

	private void readConfig() {

		Properties p = new Properties();
		InputStream in = null;

		try {
			in = AppConfig2.class.getResourceAsStream("AppConfig.Properties");
			p.load(in);
			this.parameterA = p.getProperty("paramA");
			this.parameterB = p.getProperty("paramB");

		} catch (Exception e) {
			System.out.println("装载配置文件出错了，具体堆栈信息如下：");
			e.printStackTrace();
		} finally {
			try {
				in.close();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
}
